﻿//Created by Action Script Viewer - http://www.buraks.com/asv
package Display.TrainUI {
    import flash.events.*;
    import Engine.Managers.*;
    import flash.display.*;
    import flash.geom.*;
    import Classes.*;
    import Classes.sim.*;
    import Classes.orders.*;

    public class TrainUI {

        public static const INVALID_HANDLE:int = -1;

        private static var m_slidePicks:Array = [];
        private static var m_nextAvailableHandle:int = 0;
        private static var m_trainSim:TrainManager;
        private static var m_questHudIcon:AutoAnimatedBitmap = null;

        public static function showTrainAtStationHUDIcon(_arg1:Boolean, _arg2:TrainManager):void{
            m_trainSim = _arg2;
            if (_arg1){
                if (m_questHudIcon == null){
                    LoadingManager.load(Global.getAssetURL("assets/dialogs/train/train_quest.png"), onTrainHudIconLoaded);
                };
            } else {
                Global.hud.hideTrainQuestSprite();
                if (m_questHudIcon){
                    m_questHudIcon.cleanUp();
                    m_questHudIcon = null;
                };
            };
        }
        private static function onTrainHudIconLoaded(_arg1:Event):void{
            var _local3:Bitmap;
            var _local2:Loader = (_arg1.target.loader as Loader);
            if ((_local2.content is Bitmap)){
                _local3 = (_local2.content as Bitmap);
                m_questHudIcon = new AutoAnimatedBitmap(_local3.bitmapData, 2, 64, 64, 1);
                m_questHudIcon.play();
                Global.hud.showTrainQuestSprite(m_questHudIcon, onTrainAtStationHudIconClicked);
                Global.hud.showGoalsProgressOverlayOnQuestIcon("trainAtStation", "trainAtStation");
            };
        }
        public static function onTrainAtStationHudIconClicked():void{
            m_trainSim.showTrainStationDialog();
        }
        public static function showTrainSchedule(_arg1:Boolean, _arg2:Point, _arg3:Array, _arg4:Array):void{
        }
        public static function createTrainUI(_arg1:String, _arg2:TrainManager, _arg3:TrainOrder):int{
            var _local5:Player;
            var _local4:int = m_nextAvailableHandle;
            if (_arg3.fakeTrainOrder){
                _arg1 = Player.FAKE_USER_ID_STRING;
            };
            if (_arg1 == Global.player.uid){
                _local5 = Global.player;
            } else {
                _local5 = Global.player.findFriendById(_arg1);
            };
            var _local6:String = (_local5) ? _local5.snUser.picture : null;
            if (_arg3.customPickUrl){
                _local6 = Global.getAssetURL(_arg3.customPickUrl);
            };
            var _local7:TrainSlidePick = new TrainSlidePick(_local6, m_nextAvailableHandle, _arg2, _arg3, true);
            _local7.setActive(false);
            m_slidePicks[m_nextAvailableHandle] = _local7;
            while (m_slidePicks.hasOwnProperty(m_nextAvailableHandle)) {
                m_nextAvailableHandle++;
            };
            return (_local4);
        }
        public static function closeTrainUI(_arg1:int):void{
            var slidePick:* = null;
            var handle:* = _arg1;
            if ((((handle >= 0)) && (!((m_slidePicks[handle] == null))))){
                slidePick = (m_slidePicks[handle] as TrainSlidePick);
                slidePick.kill(function ():void{
                    if (slidePick.parent){
                        slidePick.parent.removeChild(slidePick);
                    };
                });
                m_nextAvailableHandle = handle;
                delete m_slidePicks[handle];
            };
        }
        public static function showTrainUI(_arg1:int, _arg2:TrainOrder):void{
            var _local3:TrainSlidePick;
            if ((((_arg1 >= 0)) && (!((m_slidePicks[_arg1] == null))))){
                _local3 = (m_slidePicks[_arg1] as TrainSlidePick);
                _local3.showTrainUI(_arg2);
            };
        }
        public static function getTrainProfilePick(_arg1:int):TrainSlidePick{
            if (_arg1 >= 0){
                return ((m_slidePicks[_arg1] as TrainSlidePick));
            };
            return (null);
        }
        public static function setTrainProfilePickPos(_arg1:int, _arg2:Point):void{
            var _local3:TrainSlidePick;
            if ((((((_arg1 >= 0)) && (!((m_slidePicks[_arg1] == null))))) && (!((_arg2 == null))))){
                _local3 = (m_slidePicks[_arg1] as TrainSlidePick);
                _local3.setPosition(_arg2.x, _arg2.y);
            };
        }
        public static function incrementCount(_arg1:int):void{
            var _local2:TrainSlidePick;
            if ((((_arg1 >= 0)) && (!((m_slidePicks[_arg1] == null))))){
                _local2 = (m_slidePicks[_arg1] as TrainSlidePick);
                _local2.onMore(null);
            };
        }
        public static function backOnePanel(_arg1:int):void{
            var _local2:TrainSlidePick;
            if ((((_arg1 >= 0)) && (!((m_slidePicks[_arg1] == null))))){
                _local2 = (m_slidePicks[_arg1] as TrainSlidePick);
                _local2.backOnePanel();
            };
        }

    }
}//package Display.TrainUI 
